package ro.bluecube.common.persistence;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;

@MappedSuperclass
public class PersistableEntity implements Serializable {

	private Long id;
	private Long version;

	protected PersistableEntity() {
	}

	protected PersistableEntity(Long id) {
		this.setId(id);
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Id
	@Column(name="ID")
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	public void setVersion(Long version) {
		this.version = version;
	}

	@Version
	@Column(name="VERSION")
	public Long getVersion() {
		return version;
	}
}
